package com.jhhc.utils;

import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
@Service
public class ToTimeUtil {


        public LocalDateTime getDateTime(String time) {
            DateTimeFormatter formatter = null;
            if (time.length()==19) {
                 formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
                return   LocalDateTime.parse(time, formatter);
            }else if(time.length()==16)  {
                 formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm");
                return   LocalDateTime.parse(time, formatter);
            }
            return  null;

        }
}
